//
//  secondViewController.m
//  豆瓣综合网页
//
//  Created by dllo on 15/12/31.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "secondViewController.h"
#import "secondTableViewCell.h"
#import "second2ViewController.h"
#import "UIImageView+WebCache.h"
@interface secondViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) NSMutableArray *arr;
@end
@implementation secondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor redColor];
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
    [self.view addSubview:_tableView];
    [_tableView release];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    
    NSString *path = [[NSBundle mainBundle]pathForResource:@"movie" ofType:@"plist"];
    self.arr = [NSMutableArray arrayWithContentsOfFile:path];
    self.navigationItem.title = @"电影";
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBar.barTintColor =[UIColor colorWithRed:86/255.0 green:137/255.0 blue:156/255.0 alpha:1];
    UIImage *image = [UIImage imageNamed:@"rili.png"];
    image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStyleDone target:self action:@selector(itemAction:)];
    self.navigationItem.rightBarButtonItem = item;
    [self.tableView registerClass:[secondTableViewCell class] forCellReuseIdentifier:@"cell"];
   
    
}

-(void)itemAction:(UIBarButtonItem *)item {
    second2ViewController *sec2 = [[second2ViewController alloc] init];
    [self.navigationController pushViewController:sec2 animated:YES];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _arr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    secondTableViewCell *cell = [[secondTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
    cell.label.text = _arr[indexPath.row][@"title"];
    cell.bigimgView.image = [UIImage imageNamed:@"bg_eventlistcell.png"];
    NSString *str = _arr[indexPath.row][@"images"][@"large"];
    [cell.minimgView sd_setImageWithURL:[NSURL URLWithString:str]];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 200;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    second2ViewController *secon2 = [[second2ViewController alloc] init];
    [self.navigationController pushViewController:secon2 animated:YES];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
